[#ftl]
[#assign fields = formFields /]
[#assign ctx = '$' + '{ctx}' /]
<%@ page pageEncoding="utf-8" trimDirectiveWhitespaces="true" %>
<%@ include file="/WEB-INF/view/include/taglibs.jspf" %>
<%--TODO 新增和编辑都使用这个--%>
<m:h>
    <link rel="stylesheet" href="${ctx}/css/base.css"/>
    <link rel="stylesheet" href="${ctx}/css/form.css"/>
    <link rel="stylesheet" href="${ctx}/css/select2.css">
    <style type="text/css">
    </style>
</m:h>
<sf:form id="${commandName!'brand'}-form" action="${action!'action'}" method="post" commandName="${commandName!'brand'}">
    <table class="table-module01" cellpadding="0" cellspacing="0">
        <tbody>
        [#list fields as field]
        [#assign name = field.name /]
        [#assign code = field.code /]
        [#assign fname = field.fullName /]
        [#assign type = field.type /]
        <tr>
            <th width="130" align="right">
                <sf:label path="${name}" for="${name}"><spring:message code="${code}" />:</sf:label>
            </th>
            <td>
                [#if type == 'boolean']
                    <sf:input path="${name}" cssErrorClass="error" />
                [#elseif type == 'date']
                    <sf:input path="${name}" cssErrorClass="error" cssClass="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
                [#-- 转义问题,所以这里使用 --]
                [#--<sf:input id="startTime" path="startTime" cssErrorClass="error" cssClass="Wdate" htmlEscape="false"  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd', maxDate:'#F{$dp.$D(&#92;x27endTime&#92;x27)||&#92;x272099-12-31&#92;x27}'})"/>--]
                [#else]
                    <sf:input path="${name}" cssErrorClass="error"/>
                [/#if]
                <sf:errors path="${name}" element="label" cssClass="error" for="${name}"/>
            </td>
        </tr>
        [/#list]
        <tr>
            <th width="130" align="right">&nbsp;</th>
            <td>
                <span class="btn-sure-wrap"><input class="btn-sure btn-edit btn btn-primary" type="submit" value="提交"/></span>
                <span class="btn-cancel-wrap"><a class="btn-cancel btn btn-primary" href="index">取消</a></span>
            </td>
        </tr>
        </tbody>
    </table>
</sf:form>
<script type="text/javascript" src="${ctx}/js/lib/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="${ctx}/js/lib/jquery.maskedinput.min.js"></script>
<%--<script type="text/javascript" src="${ctx}/js/common.js"></script>--%>
<script src="${ctx}/js/lib/select2.min.js"></script>
<script src="${ctx}/js/lib/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script type="text/javascript" src="${ctx}/js/lib/jquery-validation-1.13.0/jquery.validate.min.js"></script>
<script type="text/javascript" src="${ctx}/js/lib/jquery-validation-1.13.0/localization/messages_zh.min.js"></script>
<script type="text/javascript">
    FM_RULES = {
    [#list fields as field]
        "${field.name}": {
        [#list field.rule?keys as key]
            [#assign v = field.rule[key] /]
            "${key}": [#if v?is_boolean]${v?string('true','false')}[#elseif v?is_number]${v?c}[#else]${v}[/#if][#if key_has_next],[/#if]
        [/#list]
        }[#if field_has_next],[/#if]
    [/#list]
    }
    $('#brand-form').validate({
        rules: FM_RULES
    })
</script>
<m:f/>
